package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ExclusiveBenefits;
import com.ruoyi.system.service.IExclusiveBenefitsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 权益管理Controller
 * 
 * @author 何志龙
 * @date 2024-09-17
 */
@RestController
@RequestMapping("/system/ExclusiveBenefits")
public class ExclusiveBenefitsController extends BaseController
{
    @Autowired
    private IExclusiveBenefitsService exclusiveBenefitsService;

    /**
     * 查询权益管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:ExclusiveBenefits:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExclusiveBenefits exclusiveBenefits)
    {
        startPage();
        List<ExclusiveBenefits> list = exclusiveBenefitsService.selectExclusiveBenefitsList(exclusiveBenefits);
        return getDataTable(list);
    }

    /**
     * 导出权益管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:ExclusiveBenefits:export')")
    @Log(title = "权益管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExclusiveBenefits exclusiveBenefits)
    {
        List<ExclusiveBenefits> list = exclusiveBenefitsService.selectExclusiveBenefitsList(exclusiveBenefits);
        ExcelUtil<ExclusiveBenefits> util = new ExcelUtil<ExclusiveBenefits>(ExclusiveBenefits.class);
        util.exportExcel(response, list, "权益管理数据");
    }

    /**
     * 获取权益管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:ExclusiveBenefits:query')")
    @GetMapping(value = "/{BenefitID}")
    public AjaxResult getInfo(@PathVariable("BenefitID") Long BenefitID)
    {
        return success(exclusiveBenefitsService.selectExclusiveBenefitsByBenefitID(BenefitID));
    }

    /**
     * 新增权益管理
     */
    @PreAuthorize("@ss.hasPermi('system:ExclusiveBenefits:add')")
    @Log(title = "权益管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExclusiveBenefits exclusiveBenefits)
    {
        return toAjax(exclusiveBenefitsService.insertExclusiveBenefits(exclusiveBenefits));
    }

    /**
     * 修改权益管理
     */
    @PreAuthorize("@ss.hasPermi('system:ExclusiveBenefits:edit')")
    @Log(title = "权益管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExclusiveBenefits exclusiveBenefits)
    {
        return toAjax(exclusiveBenefitsService.updateExclusiveBenefits(exclusiveBenefits));
    }

    /**
     * 删除权益管理
     */
    @PreAuthorize("@ss.hasPermi('system:ExclusiveBenefits:remove')")
    @Log(title = "权益管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{BenefitIDs}")
    public AjaxResult remove(@PathVariable Long[] BenefitIDs)
    {
        return toAjax(exclusiveBenefitsService.deleteExclusiveBenefitsByBenefitIDs(BenefitIDs));
    }
}
